<template>
  <div class="home">
    <div class="hero">
      <h1>Pinia 状态管理示例</h1>
      <p>Vue3 官方推荐的状态管理库</p>
    </div>

    <div class="features">
      <div class="feature-card">
        <div class="feature-icon">🔢</div>
        <h3>计数器示例</h3>
        <p>展示基本的state、getters和actions使用</p>
        <router-link to="/counter" class="feature-link">查看示例</router-link>
      </div>

      <div class="feature-card">
        <div class="feature-icon">👥</div>
        <h3>用户管理</h3>
        <p>展示复杂数据的状态管理</p>
        <router-link to="/user" class="feature-link">查看示例</router-link>
      </div>

      <div class="feature-card">
        <div class="feature-icon">⚡</div>
        <h3>响应式数据</h3>
        <p>自动追踪依赖，高效更新</p>
        <div class="feature-link disabled">已内置</div>
      </div>
    </div>

    <div class="stats">
      <div class="stat-item">
        <div class="stat-number">{{ userStore.userCount }}</div>
        <div class="stat-label">用户总数</div>
      </div>
      <div class="stat-item">
        <div class="stat-number">{{ userStore.activeUserCount }}</div>
        <div class="stat-label">活跃用户</div>
      </div>
      <div class="stat-item">
        <div class="stat-number">{{ userStore.averageAge }}</div>
        <div class="stat-label">平均年龄</div>
      </div>
    </div>
  </div>
</template>

<script>
import { useUserStore } from '@/stores/user'

export default {
  name: 'Home',
  setup() {
    const userStore = useUserStore()

    return {
      userStore
    }
  }
}
</script>

<style scoped>
.home {
  max-width: 1000px;
  margin: 0 auto;
}

.hero {
  text-align: center;
  padding: 3rem 0;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  margin-bottom: 3rem;
  backdrop-filter: blur(10px);
}

.hero h1 {
  font-size: 3rem;
  color: white;
  margin-bottom: 1rem;
  font-weight: 700;
}

.hero p {
  font-size: 1.2rem;
  color: rgba(255, 255, 255, 0.8);
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  margin-bottom: 3rem;
}

.feature-card {
  background: rgba(255, 255, 255, 0.95);
  padding: 2rem;
  border-radius: 15px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease;
}

.feature-card:hover {
  transform: translateY(-5px);
}

.feature-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.feature-card h3 {
  color: #333;
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

.feature-card p {
  color: #666;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.feature-link {
  display: inline-block;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  padding: 0.8rem 2rem;
  border-radius: 25px;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.3s ease;
}

.feature-link:hover {
  transform: scale(1.05);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.feature-link.disabled {
  background: #ccc;
  cursor: not-allowed;
}

.feature-link.disabled:hover {
  transform: none;
  box-shadow: none;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
}

.stat-item {
  background: rgba(255, 255, 255, 0.9);
  padding: 2rem;
  border-radius: 15px;
  text-align: center;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.stat-number {
  font-size: 2.5rem;
  font-weight: 700;
  color: #667eea;
  margin-bottom: 0.5rem;
}

.stat-label {
  color: #666;
  font-weight: 500;
}

@media (max-width: 768px) {
  .hero h1 {
    font-size: 2rem;
  }

  .features {
    grid-template-columns: 1fr;
  }

  .stats {
    grid-template-columns: 1fr;
  }
}
</style>
